<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- react的根元素 插入一个根组件 -->
    <div id="example"></div>
</body>
</html>
<script src="./js/react.development.js"></script>
<script src="./js/react-dom.development.js"></script>
<script src="./js/babel.js"></script>
<script type="text/babel">
    class MyComponent extends React.Component{
        constructor(props)
        {
            super(props)

            this.state = {
                login: false
            }
        }

        render()
        {
            // 在外部封装条件判断
            let login = null

            if(this.state.login)
            {
                login = <button>已经登录</button>
            }else
            {
                login = <button>暂未登录</button>
            }

            return(
                <div>
                    {login}<br /><br />
                    {this.state.login ? <button>已经登录</button> : <button>暂未登录</button>}
                </div>
            )
        }
    }

    ReactDOM.render(
        <MyComponent />,
        document.getElementById('example')
    )
</script>